<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Java档案管理</title>
<!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
<script src="libs/jquery-1.12.1.min.js"></script>
<link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript" src="libs/identity.js"></script>
</head>
<body>
	<div class="container">
		<div class="row">
			<div class="page-header">
				<h2 class="text-center">
					<strong>档案管理</strong>
				</h2>
				<div style="margin-left: 900px">
					<div class="input-group">
						<input type="text" id="shuru" class="form-control"
							placeholder="输入档案号或身份证号"> <span class="input-group-btn">
							<button id="chaxun" class="btn btn-default" type="button">Go!</button>
						</span>
					</div>
					<!-- /input-group -->
				</div>
			</div>
			<div class="col-md-8">
				<ul class="nav nav-pills">
					<li class=""><a href="index.html">首页</a></li>
					<li class="active"><a href="#">添加</a></li>
					<li class=""><a href="mohuquery.html">查询</a></li>
				</ul>
			</div>
			<div class="col-md-3 col-md-offset-1">
				<ul class="nav nav-pills">
					<li><a href="#">用户：<span id="account"></span></a></li>
					<li class=""><a href="register.html">注册</a></li>
					<li><button id="quit" class="btn btn-block">退出</button></li>
				</ul>
			</div>
		</div>
	</div>
	<div class="contrainer">
		<div class="row">
			<div class=cil-md-12>
				<hr />
			</div>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-md-4 col-md-offset-4">
				<div class="form-group">
					<label for="archive_id">档案号:</label> <input type="text"
						class="form-control" id="archive_id" />
				</div>
				<div class="form-group">
					<label for="identity">身份证号:</label> <input type="text"
						class="form-control" id="identity" />
					<button class="btn btn-default" type="button" id="checkIdentity">
						<span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span>
					</button>


				</div>
				<div class="form-group">
					<label for="name">姓名:</label> <input type="text"
						class="form-control" id="name" />
				</div>
				<div class="form-group">
					<label for="gender">性别:</label> <input type="text"
						class="form-control" id="gender" />
				</div>
				<div class="form-group">
					<label for="birthday">出生日期:</label> <input type="date"
						class="form-control" id="birthday" />
				</div>
				<div class="form-group">
					<label for="date_retire1">预退休日期:</label> <input type="date"
						class="form-control" id="date_retire1" />
				</div>
				<div class="form-group">
					<label for="date_retire2">实际退休日期:</label> <input type="date"
						class="form-control" id="date_retire2" />
				</div>
				<div class="form-group">
					<label for="sp">特殊工种:</label> <input type="text"
						class="form-control" id="sp" />
				</div>
				<div class="form-group">
					<label for="fc">女管理岗位:</label> <input type="text"
						class="form-control" id="fc" />
				</div>
				<div class="form-group">
					<label for="title">职称:</label> <input type="text"
						class="form-control" id="title" />
				</div>
				<div class="form-group">
					<label for="seniority">工龄:</label> <input type="text"
						class="form-control" id="seniority" />
				</div>
				<button id="saveadd" class="btn btn-primary btn-block">保存</button>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	$(function() {
		$.getJSON('querynickname.action', function(res) {
			console.log(res);
			$('#account').text(res.nickname);
		});
		$('#checkIdentity').click(function() {
			// console.log(getIdentityInfo($('#identity').val()));
			var identity = getIdentityInfo($('#identity').val());
			if (!identity) {
				return;
			}
			$('#gender').val(identity.gender);
			$('#birthday').val(identity.birthday);
			var dd = new Date(identity.birthday);
			dd.setYear(dd.getFullYear() + 60);
			$('#scheduled_date_of_retirement').val(dd.format('yyyy-MM-dd'));
		});
		$('#saveadd').click(function() {
			$.post('addDA.action', {
				archive_id : $('#archive_id').val(),
				identity : $('#identity').val(),
				name : $('#name').val(),
				gender : $('#gender').val(),
				birthday : $('#birthday').val(),
				date_retire1 : $('#date_retire1').val(),
				date_retire2 : $('#date_retire2').val(),
				sp : $('#sp').val(),
				fc : $('#fc').val(),
				title : $('#title').val(),
				seniority : $('#seniority').val()
			}, function(res, status) {
				if ('OK' == res) {
					alert('保存成功');
				}
			});
		});
		$('#quit').click(function() {
			$.post('quit.action', {}, function(res, status) {
				if ('OK' == res) {
					alert('退出成功');
					window.location.href = 'login.html';
				}
			});
		});
		$('#chaxun').click(function() {
			$.post('chaxun.action', {
				shuru : $('#shuru').val()
			}, function(res, stastu) {
				if ('dayuone' == res) {
					alert('有多个结果');
				} else if ('dengyuO' == res) {
					alert('输入有误');
				} else {
					console.log(res);
					window.location.href = 'one.html?id=' + res;
				}
			});
		});

	});
</script>
</html>